package com.xneure.database.dao;

import com.xneure.database.annotation.AutoUpdate;
import com.xneure.database.annotation.DBField;
import com.xneure.utils.bean.GUID;

public class DBEntity extends DataBaseTable{
	@DBField(primaryKey = true,autoUpdate = AutoUpdate.CREATE)
	private GUID id;
	@DBField(autoUpdate = AutoUpdate.CHANGE)
	private Long versions;

	public DBEntity(){
		super();
	}

	public GUID getId(){
		return id;
	}

	public void setId(GUID id){
		this.id = id;
	}

	public Long getVersions(){
		return versions;
	}

	public void setVersions(Long versions){
		this.versions = versions;
	}

	@Override
	public int hashCode(){
		final int prime = 31;
		int result = 1;
		result = prime * result + ((id == null) ? 0 : id.hashCode());
		result = prime * result + ((versions == null) ? 0 : versions.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj){
		if(null == obj){
			return false;
		}
		if(obj instanceof DBEntity){
			if(null == ((DBEntity)obj).getId()){
				return false;
			}
			return ((DBEntity)obj).getId().equals(id);
		}
		return false;
	}
}
